﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<!--借书车-->
<%
    IList booklist = (IList)ViewData["booklist"];
    string bookid = "";
     %>
<div class="take_book_box w_980">
	<div class="take_book_main">
    	<div class=" book_txt_box">
            <h3>借书车</h3>
        </div>
        <ul class="book_list_ul">
        <%
            DomainModel.UserInfo user = (DomainModel.UserInfo)Session["user"]; 
            BIZ.LibraryBookIndentOper bookOper=new BIZ.LibraryBookIndentOper();
            if (booklist != null)
            {
                foreach (Hashtable tb in booklist)
                {
                    Response.Write("<li>");
                    Response.Write("<a href=\"/search/detail.html?id=" + tb["lb_id"] + "\" class=\"book_img_a\"><img  src=\"" + BIZ.StringTool.changeImgUrl((tb["lb_cover"] == null ? "" : tb["lb_cover"].ToString())) + "\"  /></a>");
                    //Response.Write("<input name=\"\" type=\"checkbox\" value=\"\" class=\"checkbox_style\" />");
                    Response.Write("<div class=\"book_list_txt\">");
                    Response.Write("<h2><a href=\"/search/detail.html?id=" + tb["lb_id"] + "\">" + tb["lb_bookName"] + "</a>");
                    if (!string.IsNullOrEmpty(tb["lb_translatedName"].ToString()))                        
                        Response.Write("<strong>译名：" + tb["lb_translatedName"] + "</strong>");
                    Response.Write("</h2>");
                    Response.Write("<p><strong>年龄：" + Enum.GetName(typeof(DAL.Enums.bookforAge), int.Parse(tb["lb_forAge"].ToString())).ToString().Replace("_", "") + "</strong></p>");
                    Response.Write("<p><label>价格</label>：<b>" + tb["lb_price"] + "</b>元</p>");
                    Response.Write("<p><label>级别</label>：" + Enum.GetName(typeof(DAL.Enums.boollevel), int.Parse(tb["lb_level"].ToString())) + "</p>");
                    Response.Write("</div>");
                    Response.Write("<a href=\"#\" onclick=\"delLibrary("+tb["lb_id"]+")\" class=\"btn_del\" title=\"删除\">删除</a>");
                    if (bookOper.getCountByBookIdUid(int.Parse(tb["lb_id"].ToString()),user.u_id)>0)
                    {
                        Response.Write("<div class=\"bg_yy\">已阅</div>");
                    }
                    Response.Write("</li>");
                    if (bookid == "")
                        bookid = tb["lb_id"].ToString();
                    else
                        bookid = bookid + "," + tb["lb_id"].ToString();
                }
            }
       %>
            <!--1-->
        </ul>
        <input type="hidden" value="<%=bookid %>" id="bid" name="bid" />
    </div>
    <%--<div class="take_book_bar"><input name="" type="checkbox" value="" />全选<a href="#">删除</a></div>--%>
    <div class="btn_sub"><a href="javascript:void(0);" id="buttEdit" title="提交">提交</a></div>
</div>
<script type="text/javascript">
    $(function () {
        //tab切换
        $(".book_list_tab li").eq(0).addClass("select_tab");
        $(".book_list_main > ul").eq(0).show();
        $(".book_list_tab li").click(function () {
            $(this).addClass("select_tab").siblings().removeClass("select_tab");
            var i = $(this).index();
            $(".book_list_main > ul").eq(i).show().siblings().hide();
        })
    })

    function delLibrary(lb_id) {
        $.post("/Search/delLibrary.html", { lb_id: lb_id }, function (dta) {
            alert("删除成功");
            window.location.reload();
        });
    }
    $(document).ready(function () {
        $("#buttEdit").click(function () {
            if ($("#bname").val() == "") {
                alert("请选择图书");
                $("#bname").focus();
                return false;
            }
            $.post("/Search/saveLibraryBookIndent.html", { lbid: $("#bid").val() }, function (dta) {
                if (dta == "succe") {
                    alert("借书成功");
                    window.location.href = "/vipcenter/currentlist.html?f=e2";
                }
                else if (dta == "notimes") {
                    alert("借书失败，充值卡无剩余次数，或已经过期");
                }
                else if (dta == "erroruserrule") {
                    alert("借书失败，临时会员无法借书");
                }
                else if (dta == "erroruser") {
                    alert("借书失败");
                }
                else if (dta == "best4") {
                    alert("借书失败，您最多手持图书量为4本");
                }
                else if (dta == "nocard") {
                    alert("借书失败，您没有购买充值卡，请联系我们");
                }
                else if (dta == "bbcz") {
                    alert("借书失败，图书不存在");
                } //
                else if (dta == "bnkc") {
                    alert("借书失败，库存不足");
                }
                else if (dta == "bxj") {
                    alert("借书失败，图书已下架");
                }
                else if (dta == "bdzs") {
                    alert("借书失败，电子书不能进入借书流程");
                }
                else {
                    alert("借书失败");
                }
            });
        });

    });
</script>
</asp:Content>
